<template>
    <div>
        <h3>我是ComA---{{ props.data1 }} ---{{ $attrs.data2 }}</h3>
        <button @click="getParent($parent)">获取父组件的实例</button>
        <ComB v-bind="$attrs"></ComB>
    </div>
</template>

<script setup lang='ts'>
import { ref, useAttrs } from 'vue';
import ComB from './ComB.vue';
const props = defineProps<{
    data1:string
}>()
const attrs = useAttrs()
//通过parent获取父组件的数据
const sondata = ref('我是子组件的数据')
defineExpose({
    sondata
})
const getParent = (el:any)=>{
    console.log(el.data)
}
</script>

<style scoped lang = 'scss'>

</style>